package com.paginasenlanube.dao;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


import com.paginasenlanube.model.Page;


@Repository("pageDao")
public class PageDaoImpl {
	
	@Autowired
	@Qualifier("hibernateDao")
	private GenericDao dao;
	
	
	public GenericDao getDao() {
		return dao;
	}


	public void updatePage(Page p,String pageName,boolean showPage, int pagePosition) {
		
		p.setName(pageName);
		p.setShowPage(showPage);
		p.setPosition(pagePosition);
		dao.update(p);	
				
	}
	

	public List<Page> getPages(long menuId) {	
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("menu_id", menuId);
		Order order = Order.asc("position");
		List<Page> pages = dao.getObjectsByEqCriteria(Page.class, params, order);
		return  pages;
	}
	

}
